package com.example.rental.service.impl;

import com.example.rental.entity.Collect;
import com.example.rental.entity.Houseinfo;
import com.example.rental.entity.dto.CollectDto;
import com.example.rental.mapper.CollectMapper;
import com.example.rental.result.Result;
import com.example.rental.service.CollectService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CollectServiceImpl implements CollectService {
    @Autowired
    private CollectMapper collectMapper;
    @Override
    public Result getCollect(CollectDto collectDto) {
        PageHelper.startPage(collectDto.getPage(), collectDto.getLimit());

        List<Collect> list = collectMapper.getCollect(collectDto);

        Page page = (Page) list;
        Result result = Result.ok(list);
        result.setCount(page.getTotal());

        return result;
    }
    @Override
    public void deleteCollect(Collect collect){collectMapper.deleteCollect(collect);};
    @Override
    public void addCollect(Collect collect){collectMapper.addCollect(collect);};
}
